package com.dreamtour.mapper;

import com.dreamtour.entity.Cities;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xls
 * @since 2024-12-24
 */
public interface CitiesMapper extends BaseMapper<Cities> {

    @Select("SELECT c.cityName, COUNT(u.uId) AS userCount " +
            "FROM Cities c " +
            "LEFT JOIN Users u ON c.cityId = u.cityId " +
            "GROUP BY c.cityName " +
            "ORDER BY userCount DESC")
    List<Map<String, Object>> getCityDistribution();
}
